package one.three.twenty;

public class Delete {

	private static class Node<Item> {
		private Item item;
		private Node next;
	}

	private static void delete(Node n, int k) {
		int i = 0;
		while (n != null) {
			i++;
			if (i == k - 1 && n.next != null) {
				Node t = n.next.next;
				n.next = t;
				return;
			}
			n = n.next;
		}
	}

	public static void main(String[] args) {
		Node<String> f = new Node<String>();
		f.item = "0";
		Node<String> c = f;
		for (int i = 1; i <= 10; i++) {
			c.next = new Node<String>();
			c.next.item = i + "";
			c = c.next;
		}
		
		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}
		delete(f, 5);
		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}
		
	}

}
